﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mozlite.Components
{
    /// <summary>
    /// 禁用名称。
    /// </summary>
    public class DisallowNames : BaseConfiguration<DisallowNames>
    {
        /// <summary>
        /// 禁用名称。
        /// </summary>
        public string Names { get; set; }
        /// <summary>
        /// 是否为禁用名称。
        /// </summary>
        /// <param name="name">当前名称。</param>
        /// <returns>返回判断结果。</returns>
        public bool IsDeny(string name)
        {
            if ((Names.HasValue() && ("\n" + Names.Replace("\r\n", "\n") + "\n").IndexOf("\n" + name + "\n", StringComparison.OrdinalIgnoreCase) != -1) ||
                (IsAppendBadWords&&Globals.WordFilter.HasKey(name)))
                return true;
            return false;
        }
        /// <summary>
        /// 是否附加脏词。
        /// </summary>
        public bool IsAppendBadWords { get; set; }
    }
}
